<template>
  <div class="wrap-box">
    <topone></topone>
    <router-view></router-view>
    <bottomtop></bottomtop>
  </div>
</template>

<script>
import Topone from './top/top'
import Bottomtop from './bottom/bottom'
import axios from 'axios'
import $ from 'jquery'
export default {
  data () {
    return {
      columnData: [],
      islogin: '',
      searchData: [],
      topAd: [],
      tottomAd: []
    }
  },
  components: {
    Topone,
    Bottomtop
  },
  methods: {
    getCity () {
      var that = this
      // $.ajax({
      //   url: 'http://api.map.baidu.com/location/ip?ak=ia6HfFL660Bvh43exmH9LrI6',  
      //   type: 'POST',  
      //   dataType: 'jsonp',
      //   success:function(data) {
      //     console.log(that.$store.state.province)
      //     console.log(that.$store.state.city)
      //     if (that.$store.state.city === '') {
      //       that.$store.commit('changeProvi', data.content.address_detail.province)
      //       console.log(data.content.address_detail.province)
      //       console.log(data.content.address_detail.city)
      //       that.$store.commit('changeCity', data.content.address_detail.city)
      //     }
      //   }
      // })
    },
    isLogin: function () {
      var that = this
      that.$axios.request('/Account/GetUserState')
        .then((res) => {
          if (res.code === 0) {
            if (res.data.state === 1) {
              that.$store.commit('islogin', res.data.mark)
            } else {
              $.ajax({
                url: that.$axios.link + '/Account/GetUserState',
                type: 'post',
                dataType: 'json',
                xhrFields: {
                  withCredentials: true
                },
                success: function (data) {
                  if (data.code === 0) {
                    if (data.data.state === 1) {
                      that.$store.commit('islogin', data.data.mark)
                    }
                  }
                }
              })
            }
          }
        })
    }
  },
  mounted () {
    this.isLogin()
    // this.getCity()
    // this.getAd()
  }
}
</script>
